#include <stdio.h>
#include <stdlib.h>
#include <memory.h>
#include <assert.h>

#include "aba_memory.h"

void init_memory(char memory[], size_t size)
{
	memset(memory, 0, size);
	/* DEBUG */
	if (size > 13)
		memcpy(memory, "Hello, world!", 13);
}

void dump_memory(char memory[], size_t start, size_t end)
{
	size_t i, j;
	assert(start <= end && end < MAXMEM);
	
	for (i=start; i<end-4; i+=4) {
		printf("%8x: %2x %2x %2x %2x\n", 
		       i,
		       memory[i],
		       memory[i+1],
		       memory[i+2],
		       memory[i+3]);
	}
	/* dump the remaining 0~3 bytes */
	printf("%8x: ", i);
	while (i<end)
		printf("%2x ", memory[i++]);
	printf("\n");
}
